javax.realtime
Class ScopedMemory

java.lang.Object
  extended byjavax.realtime.MemoryArea
      extended byjavax.realtime.ScopedMemory
Direct Known Subclasses:
LTMemory

public abstract class ScopedMemory
extends MemoryArea

ScopedMemory is the abstract base class of all classes dealing with representations of memory spaces which have a limited lifetime. In general, objects allocated in scoped memory are freed when (and only when) no schedulable object has access to the objects in the scoped memory.

A ScopedMemory area is a connection to a particular region of memory and reflects the current status of that memory. The object does not necessarily contain direct references to the region of memory. That is implementation dependent.

When a ScopedMemory area is instantiated, the object itself is allocated from the current memory allocation context, but the memory space that object represents (its backing store) is allocated from memory that is not otherwise directly visible to Java code; e.g., it might be allocated with the C malloc function. This backing store behaves effectively as if it were allocated when the associated scoped memory object is constructed and freed at that scoped memory object's finalization.

The enter() method of ScopedMemory is one mechanism used to make a memory area the current allocation context. The other mechanism for activating a memory area is making it the initial memory area for a real-time thread or async event handler. Entry into the scope is accomplished, for example, by calling the method:public void enter(Runnable logic) where logic is a instance of Runnable whose run() method represents the entry point of the code that will run in the new scope. Exit from the scope occurs between the time the runnable.run() method completes and the time control returns from the enter method. By default, allocations of objects within runnable.run() are taken from the backing store of the ScopedMemory.

ScopedMemory is an abstract class, but all specified methods include implementations. The responsibilities of MemoryArea, ScopedMemory and the classes that extend ScopedMemory are not specified. Application code should not extend ScopedMemory without detailed knowledge of its implementation.

Not currently implemented


Field Summary
 
Fields inherited from class javax.realtime.MemoryArea
logic, sizeEstimator, sizeInBytes
 
Constructor Summary
ScopedMemory(long size)
          Create a new ScopedMemory area with the given parameters.
ScopedMemory(long size, java.lang.Runnable logic)
          Create a new ScopedMemory area with the given parameters.
ScopedMemory(SizeEstimator size)
          Create a new ScopedMemory area with the given parameters.
ScopedMemory(SizeEstimator size, java.lang.Runnable logic)
          Create a new ScopedMemory area with the given parameters.
 
Methods inherited from class javax.realtime.MemoryArea
enter, enter, executeInArea, getMemoryArea, memoryConsumed, memoryRemaining, newArray, newInstance, newInstance
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ScopedMemory

public ScopedMemory(long size)
Create a new ScopedMemory area with the given parameters.

Parameters:
size - The size of the new ScopedMemory area in bytes.

ScopedMemory

public ScopedMemory(long size,
                    java.lang.Runnable logic)
Create a new ScopedMemory area with the given parameters.

Parameters:
size - The size of the new ScopedMemory area in bytes.
logic - The Runnable to execute when this ScopedMemory is entered. If logic is null, this constructor is equivalent to constructing the memory area without a logic value.

ScopedMemory

public ScopedMemory(SizeEstimator size)
Create a new ScopedMemory area with the given parameters.

Parameters:
size - The size of the new ScopedMemory area estimated by an instance of SizeEstimator.

ScopedMemory

public ScopedMemory(SizeEstimator size,
                    java.lang.Runnable logic)
Create a new ScopedMemory area with the given parameters.

Parameters:
size - The size of the new ScopedMemory area estimated by an instance of SizeEstimator.
logic - The logic which will use the memory represented by this as its initial memory area. If logic is null, this constructor is equivalent to constructing the memory area without a logic value.